package vcp.client.GUI.mvc.model;

import vcp.client.forms.PeriodicForm;
import vcp.client.interfaces.IObservable;
import vcp.client.request.RetrieveStatisticsRequest;
import vcp.client.statistics.StatisticsAbstract;
import vcp.entity.Worker;

public class UIStatisticsModel extends UIAbstractModel
{
	// ****************************************************************************************************************************
	// Setter-Getter methods
	// ****************************************************************************************************************************
	private Worker CEO;

	public Worker getCEO ()
	{
		return this.CEO;
	}

	public void setCEO ( Worker cEO )
	{
		this.CEO = cEO;
	}

	private StatisticsAbstract statisticsReport;

	public StatisticsAbstract getStatisticsReport ()
	{
		return this.statisticsReport;
	}

	public UIStatisticsModel ( IObservable model )
	{
		super(model);
	}

	public void retrieveStatistics ( PeriodicForm form )
	{
		RetrieveStatisticsRequest request = new RetrieveStatisticsRequest(form);
		this.sendRequest(request, true);
	}

	// ****************************************************************************************************************************
	// UIAbstractModel methods
	// ****************************************************************************************************************************
	@Override
	public void clearModel ()
	{
		this.CEO = null;
		this.statisticsReport = null;
	}

	// ****************************************************************************************************************************
	// IObserver methods
	// ****************************************************************************************************************************
	@Override
	public void update ( Object data )
	{
		if ( data instanceof StatisticsAbstract )
		{
			this.statisticsReport = (StatisticsAbstract) data;
			this.controllerDelegate.updateControllerDelegateWithData(data);
		}

		this.controllerDelegate.loadingStop();
	}

}
